package com.tianbao54.kotlin_01

class Student(private val username: String, private val age: Int, private var address: String) {

    fun printlnInfo() {
        println("username = $username , age = $age , address = $address")
    }
}

/**
 * 如果构造方法拥有注解或是可见性修饰符，那么 constructor 不可省略
 */
class Student2 private constructor (username:String) {

}

/**
 * 在 jvm 上，如果类的 primary 构造方法的所有的参数都拥有默认值 ，那么 kotlin 编译器会为这个类生成一个不带参数的构造方法。。
 */
class Student3 (var username: String = "zhangsan") {

}

fun main(args: Array<String>) {

    var student = Student("zhangsan",20 ,"shenzhen")
    student.printlnInfo()

    var student3 = Student3()
    println(student3.username)
    student3 = Student3("lisi")
    println(student3.username)
}